/*! \file pres_parser.l
 *
 * \brief Flex file describing the tokens in inspector templates.
 *
 * \date Started: 5/17/2010
 * \date Last Modified: 6/28/2010
 * \authors Michelle Strout Alan LaMielle Nicholas Jeanette
 *
 * Copyright (c) 2010, Colorado State University <br>
 * All rights reserved. <br>
 * See ../../COPYING for details. <br>
*/

%{
    #include <iostream>
    #include <iegenlib/iegenlib.h>
    #include "gen_pres_parser_bin.hh"

    #define YY_NO_UNPUT
    #undef YY_INPUT

    extern int iegenlib::pres_parser::string_get_next_char();

    #define YY_INPUT(buf,result,max_size) \
    { \
        int c = iegenlib::pres_parser::string_get_next_char(); \
        result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \
    }

%}
/*produces a integer*/
DIGIT    [0-9]+
/*produces an identifier*/
IDENT    [a-zA-Z][a-zA-Z0-9'_]*
/*produces the word and*/
WORDAND  [aA][nN][dD]

/* Define all symbols that are used*/
/*NOTE: NOT symbol not included if one wishes add "!="     {return NEQ;} to the
list of symbols below*/
%%
"+"      {return PLUS;}
"-"      {return DASH;}
"*"      {return STAR;}
"{"      {return LBRACE;}
"}"      {return RBRACE;}
"["      {return LBRACKET;}
"]"      {return RBRACKET;}
"("      {return LPAREN;}
")"      {return RPAREN;}
","      {return COMMA;}
":"      {return COLON;}
"="      {return EQ;}
"<"      {return LT;}
">"      {return GT;}
"<="     {return LTE;}
">="     {return GTE;}
"->"     {return ARROW;}
"&&"     {return AND;}
";"      {return SEMI;}
"UNION"  {return UNION;}
"union"  {return UNION;}
"OR"     {return OR;}
"or"     {return OR;}
"exists" {return EXISTS;}

{WORDAND} {return WAND;}

{IDENT} { yylval.sval = new string(yytext);
          return ID;}

{DIGIT} { yylval.ival = atoi(yytext);
          return INT;}

[ \t\n\r]  /* skip whitespace */

<<EOF>> { return 0; };

%%

int yywrap() { return 1; }

